package com.lesson01;

public class Test03 {
    public static void main(String[] args) throws ClassNotFoundException {
        Person person = new Student();
        System.out.println("这个人是"+person);
        //通过对象获得
        Class c1 = person.getClass();
        System.out.println(c1.getName());
        //forname获得
        Class c2 = Class.forName("com.lesson01.Student");
        System.out.println(c2.getName());
        //通过类获得
        Class c3 = Student.class;
        System.out.println(c3.getName());
        //基本类型的包装类都有Type属性
        Class c4 = Integer.TYPE;
        System.out.println(c4.getName());
        //获得父类类型
        Class c5 = c1.getSuperclass();
        System.out.println(c5.getName());
    }
}
class Person{
    public String name;

    @Override
    public String toString() {
        return name;
    }

    public Person(String name) {
        this.name = name;
    }
    public Person() {
    }

    public String getName(){
        return name;
    }
}
class Student extends Person{
    public Student(){
        this.name = "student";
    }
}
class Teacher extends Person{
    public Teacher() {
        this.name = "teacher";
    }
}